home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / include / SetupFields.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.9 KB  |  118 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. ////////////////////////////////////////////////////////////////////////
  18. // SetupFields --
  19. ////////////////////////////////////////////////////////////////////////
  20. #ifndef SETUPFIELDS_H
  21. #define SETUPFIELDS_H
  22.  
  23. #include "Database.h"
  24.  
  25. #include "OkStr.h"
  26. #include "OkLabeledComponent.h"
  27. #include "OkText.h"
  28. #include "OkToggleButton.h"
  29.  
  30. #include <Vk/VkGenericDialog.h>
  31. #include <Vk/VkOptionMenu.h>
  32.  
  33.  
  34. class SetupFields : public VkGenericDialog, public Persistent {
  35.  
  36.  public:
  37.   enum Field { NONE=-1, NAME, PHONE1, PHONE2, FAX, MOBILE_PHONE, EMAIL, 
  38.     ADDRESS_LINE1, ADDRESS_LINE2, CITY, STATE, ZIP, COUNTRY, TOTAL_FIELDS };
  39.  
  40.  private:
  41.   IntKey    _key;
  42.  
  43.   static VkMenuDesc _fieldsDesc[];
  44.  
  45.   VkOptionMenu*            _fieldsOptionMenu;
  46.   OkLabeledComponent<OkText>*     _fieldLabelWidget;
  47.   OkLabeledComponent<OkText>*     _fieldLenWidget;
  48.   OkToggleButton*        _showInListToggle;
  49.  
  50.   Field _prevField;
  51.   void setup( Field f=NAME );
  52.   void loadSavedValues();
  53.   void saveCurrentValues();
  54.   // Return FALSE if there is an illegal input.
  55.   Boolean getCurrentUserInput( Field f );
  56.   void populateWidgets( Field f );
  57.  
  58.   // Callback stubs.
  59.   static void setupNameCB( Widget, XtPointer obj, XtPointer ) 
  60.         { ((SetupFields *)obj)->setup( NAME ); }
  61.   static void setupPhone1CB( Widget, XtPointer obj, XtPointer ) 
  62.         { ((SetupFields *)obj)->setup( PHONE1 ); }
  63.   static void setupPhone2CB( Widget, XtPointer obj, XtPointer ) 
  64.         { ((SetupFields *)obj)->setup( PHONE2 ); }
  65.   static void setupFaxCB( Widget, XtPointer obj, XtPointer ) 
  66.         { ((SetupFields *)obj)->setup( FAX ); }
  67.   static void setupMobilePhoneCB( Widget, XtPointer obj, XtPointer ) 
  68.         { ((SetupFields *)obj)->setup( MOBILE_PHONE ); }
  69.   static void setupEmailCB( Widget, XtPointer obj, XtPointer ) 
  70.         { ((SetupFields *)obj)->setup( EMAIL ); }
  71.   static void setupAddressLine1CB( Widget, XtPointer obj, XtPointer ) 
  72.         { ((SetupFields *)obj)->setup( ADDRESS_LINE1 ); }
  73.   static void setupAddressLine2CB( Widget, XtPointer obj, XtPointer ) 
  74.         { ((SetupFields *)obj)->setup( ADDRESS_LINE2 ); }
  75.   static void setupCityCB( Widget, XtPointer obj, XtPointer ) 
  76.         { ((SetupFields *)obj)->setup( CITY ); }
  77.   static void setupStateCB( Widget, XtPointer obj, XtPointer ) 
  78.         { ((SetupFields *)obj)->setup( STATE ); }
  79.   static void setupZipCB( Widget, XtPointer obj, XtPointer ) 
  80.         { ((SetupFields *)obj)->setup( ZIP ); }
  81.   static void setupCountryCB( Widget, XtPointer obj, XtPointer ) 
  82.         { ((SetupFields *)obj)->setup( COUNTRY ); }
  83.  
  84.   // Internal data storage.
  85.   Boolean    _showInList[ TOTAL_FIELDS ];
  86.   Boolean    _newShowInList[ TOTAL_FIELDS ];
  87.   OkStr        _fieldLabel[ TOTAL_FIELDS ];
  88.   OkStr     _newFieldLabel[ TOTAL_FIELDS ];
  89.   int        _fieldLen[ TOTAL_FIELDS ];
  90.   int        _newFieldLen[ TOTAL_FIELDS ];
  91.  
  92.  protected:
  93.   // Persistent functions.
  94.   void Read();
  95.   void Write();
  96.  
  97.   Widget createDialog( Widget );
  98.   void apply(Widget, XtPointer); // (factory) Default btn.
  99.   void ok(Widget, XtPointer);
  100.   void cancel(Widget, XtPointer);
  101.  
  102.  
  103.  public:
  104.   SetupFields();
  105.   ~SetupFields();
  106.  
  107.   void save();
  108.   void setFactoryDefault();
  109.   Boolean showInList( Field f ) const        { return _showInList[ f ]; }
  110.   const char* fieldLabel( Field f ) const    { return _fieldLabel[ f ]; }
  111.   int fieldLen( Field f ) const            { return _fieldLen[ f ]; }
  112.  
  113. };
  114.  
  115. extern SetupFields* theSetupFields;
  116.  
  117. #endif
  118.